package com.info.zhiduoduo.repository.mapper.address;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.info.zhiduoduo.repository.entity.taxer.TaxerRate;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.math.BigDecimal;
import java.util.List;

public interface TaxRateMapper extends BaseMapper<TaxerRate> {

    @Insert(" insert into zdd_tax_rate(userid,address_id,tax_rate) values(#{userid},#{address_id},#{tax_rate}) ")
    Boolean insertTaxRate(@Param("userid") Integer userid,@Param("address_id") Integer addressId,@Param("tax_rate") BigDecimal taxRate);

    @Select("select id from zdd_address_tax_rate where and_judge=2 and tax_type=2 " +
            " and addid=(select opening_location from zdd_maker_account where userid=#{userid})")
    Integer selectIdByUesrid(@Param("userid") Integer userid);

    @Update("update zdd_tax_rate set userid=#{userid},address_id=#{address_id},tax_rate=#{tax_rate} where tax_rate_id=#{tax_rate_id} ")
    Boolean updateTaxRate(@Param("userid") Integer userid,@Param("address_id") Integer addressId,@Param("tax_rate") BigDecimal taxRate,@Param("tax_rate_id") Integer taxRateId);

}
